/*
* @Author: Turbidsoul Chen
* @Date:   2016-01-19 18:29:07
* @Last Modified by:   Turbidsoul Chen
* @Last Modified time: 2017-01-04 18:14:15
*/

'use strict';
import webpack from 'webpack';
import yargs from 'yargs'

const { optimizeMinimize } = yargs.alias('p', 'optimize-minimize').argv;
const nodeEnv = optimizeMinimize ? 'production' : 'development';

export default {
  devtool: optimizeMinimize ? 'source-map' : false,
  entry:  {
    ReactRouterAmazeUI: './src/index.js'
  },
  resolve: {
    extensions: ['.js', '.json', '.css', '.jsx', '.sass', '.scss']
  },
  output: {
    path: './lib',
    filename: optimizeMinimize ? '[name].min.js' : '[name].js',
    library: 'ReactRouterAmazeUI',
    libraryTarget: 'umd'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: '/node_modules/',
        loader: 'babel-loader'
      },
      {
        test: /\.jsx$/,
        exclude: '/node_modules/',
        loader: 'babel-loader',
      },
      {
        test: /\.(jsx|js)$/,
        exclude: '/node_modules/',
        loader: 'eslint-loader'
      }
    ]
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': { NODE_ENV: JSON.stringify(nodeEnv) },
    })
  ]
};
